<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 3.11</title>
</head>

<body>
<?php
	if(isset($_POST['mang']))
	{
		$arr=explode(",",$_POST['mang']);
		$x=array_count_values($arr);
		foreach($x as $pt=>$gia_tri)
		{
			$lanxuathien.="$pt:$gia_tri   ";
		}
		$duy_nhat=array_unique($arr);
		$mangduynhat=implode(",",$duy_nhat);
	}
?>
<form id="form1" name="form1" method="post" action="Bai3_11.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#FFCC33" style="text-align: center; font-size: 24px; color: #930; font-weight: bold; font-style: italic;">
      <td colspan="2">ĐẾM SỐ LẦN XUẤT HIỆN VÀ TẠO MẢNG<br /> DUY NHẤT</td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">Mảng:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><input name="mang" type="text" id="mang" value="<?php echo $_POST['mang'];?>" size="80%" /></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">Số lần xuất hiện:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><input name="lanxuathien" type="text" disabled="disabled" id="lanxuathien" style="background-color:#9F9; color:#F00; font-weight:bold" value="<?php echo $lanxuathien;?>" size="80%" /></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">Mảng duy nhất:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><input name="mangduynhat" type="text" disabled="disabled" id="mangduynhat" style="background-color:#9F9; color:#F00; font-weight:bold" value="<?php echo $mangduynhat;?>" size="80%" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF">&nbsp;</td>
      <td bgcolor="#FFCCFF"><input type="submit" style="background-color:#969" name="button" id="button" value="Thực hiện" /></td>
    </tr>
    <tr style="text-align: center">
      <td colspan="2" bgcolor="#FFCCFF"><span style="text-align: center">(<span style="color: #C00; font-weight: bold;">Ghi chú</span>: Các phần tử trong mảng sẽ cách nhau bằng dấu &quot;,&quot;)</span></td>
    </tr>
  </table>
</form>
</body>
</html>